using System.Data;
using MySqlConnector;

namespace Front._1120;

public partial class Dbquick : Form
{
    public Dbquick()
    {
        InitializeComponent();
    }

    private void button1_Click_1(object sender, EventArgs e)
    {
        using var connection = new MySqlConnection("Server=localhost;port=3306;user=root;password=123456#;Database=book");
        connection.Open();
        string sql = "SELECT * FROM admin_info where admin_account = @account and admin_password = @password";
        using var command = new MySqlCommand(sql , connection);
        //get meta
        // command.Parameters.AddWithValue("account", view.);
        // command.Parameters.AddWithValue("password", pwd);
        using var reader = command.ExecuteReader();

        // while (reader.Read())
        // {
        //     richTextBox1.AppendText(reader.GetInt32(0) + Environment.NewLine);   // 或 GetInt32(0)
        // }

        while (reader.Read())
        {
            for (int i = 0; i < reader.FieldCount; i++)
            {
                richTextBox1.AppendText(reader[i] + "\t");
            }
            richTextBox1.AppendText(Environment.NewLine);
        }
    }


    private void button2_Click(object sender, EventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void richTextBox1_TextChanged(object sender, EventArgs e)
    {

    }
}